package com.homework.HomeAcount.controller;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.homework.HomeAcount.entity.CurrentUser;

@Controller
public class IndexController {
	
	@RequestMapping("/")
	public String index(Model model) {
		//从shiro的session中取currentUser
		Subject subject = SecurityUtils.getSubject();
		//取身份信息
		CurrentUser currentUser = (CurrentUser) subject.getPrincipal();
		//通过model传到页面
		model.addAttribute("menus", currentUser.getMenus());
		
		return "index";
	}
	
	@RequestMapping("/welcome")
	public String welcome() {
		return "welcome";
	}
}
